package org.bridge;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

public class ObjectContainer implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3726772555737976319L;
	private static  ThreadLocal session=new ThreadLocal();
	
	
	private static ObjectContainer container ;
	private ObjectContainer(){}

	public static ObjectContainer getInstance(){
		if(container==null){
			container = new ObjectContainer();
		}
		return container;
	}
	
	public void setAttribute(String name, Object value){
		Map c = (Map) session.get();
		if(c==null){
			c = new Hashtable();
		}
		c.put(name, value);
		System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
		System.out.println(c);
		System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
		session.set(c);
	}
	
	public Object getAttribute(String name){
		Map c = (Map) session.get();
		System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
		System.out.println(c);
		System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
		if(c==null){
			c = new Hashtable();
		}
		return c.get(name);
	}
}
